package org.hadoop.flume;
import org.apache.flume.Event;
import org.apache.flume.api.RpcClient;
import org.apache.flume.api.RpcClientFactory;
import org.apache.flume.event.EventBuilder;
import java.nio.charset.Charset;
import java.util.Scanner;
public class ThriftSender {
    public static void main(String[] args) throws Exception {
        String host = "server201";
        int port = 4141;
        RpcClient client = RpcClientFactory.getThriftInstance(host,port);
        //连续输入数据
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.nextLine();
            if(str.equals("exit")){
                break;
            }
            Event event =  EventBuilder.withBody(str, Charset.forName("UTF-8"));
            client.append(event);
        }
        client.close();
    }
}
